#include "tryicon.h"

void tryicon_init(struct tryicon* tryicon, HWND parent)
{
    memset(&tryicon->data, 0, sizeof(NOTIFYICONDATA_V2_SIZE));
    tryicon->data.cbSize = NOTIFYICONDATA_V2_SIZE;
    tryicon->data.hWnd = parent;
    tryicon->data.uID = ID_TRAY_APP_ICON;
    tryicon->data.uFlags = NIF_ICON | NIF_MESSAGE;
    tryicon->data.uCallbackMessage = WM_TRAYICON;
    tryicon->data.hIcon = LoadIcon(NULL, IDI_WINLOGO);
    Shell_NotifyIcon(NIM_ADD, &tryicon->data);
    tryicon->data.uVersion = NOTIFYICON_VERSION_4;
    Shell_NotifyIcon(NIM_SETVERSION, &tryicon->data);
}

void tryicon_delete(struct tryicon* tryicon)
{
    Shell_NotifyIcon(NIM_DELETE, &tryicon->data);
}

void tryicon_display(struct tryicon* tryicon, const wchar_t* info)
{
    tryicon->data.uFlags = NIF_INFO;
    wcscpy_s(tryicon->data.szInfo, 256, info);
    wcscpy_s(tryicon->data.szInfoTitle, 64, L"email");
    Shell_NotifyIcon(NIM_MODIFY, &tryicon->data);
}
